package com.dynamicdatasource.config;

/**
 * 动态数据源上下文
 */
public class DynamicDataSourceContextHolder{
    private static final ThreadLocal<String> dataSources = new ThreadLocal<String>(){
    	@Override
    	protected String initialValue() {
    		return "master";
		}
    };
    
    //设置数据源
    public static void setDataSource(String customerType) {
        dataSources.set(customerType);
    }

    //获取数据源
    public static String getDataSource() {
        return dataSources.get();
    }

    //清除数据源
    public static void clearDataSource() {
        dataSources.remove();
    }
    
}
